using System;
using System.Collections;
using System.DirectoryServices;

namespace BEGDC.CC.Entity
{
	#region HotelRoomBooking

	/// <summary>
	/// HotelRoomBooking object for NHibernate mapped table 'HotelRoomBooking'.
	/// </summary>
	[Serializable]
	public class HotelRoomBooking : System.IComparable
		{
		#region Member Variables
		
		protected int _id;
		protected int _hotelRoomTypeID;
		protected int _roomNumber;
		protected int _hotelID;
		protected LogisticalInfo _logisticalInfo;
		protected string _hotelname;
		protected static String _sortExpression = "Id";
		protected static SortDirection _sortDirection = SortDirection.Ascending;

		#endregion

		#region Constructors

		public HotelRoomBooking() { }

		public HotelRoomBooking( int hotelRoomTypeID, int roomNumber, int hotelID, LogisticalInfo logisticalInfo, string hotelname )
		{
			this._hotelRoomTypeID = hotelRoomTypeID;
			this._roomNumber = roomNumber;
			this._hotelID = hotelID;
			this._logisticalInfo = logisticalInfo;
			this._hotelname = hotelname;
		}

		#endregion

		#region Public Properties

		public int Id
		{
			get {return _id;}
			set {_id = value;}
		}

		public int HotelRoomTypeID
		{
			get { return _hotelRoomTypeID; }
			set { _hotelRoomTypeID = value; }
		}

		public int RoomNumber
		{
			get { return _roomNumber; }
			set { _roomNumber = value; }
		}

		public int HotelID
		{
			get { return _hotelID; }
			set { _hotelID = value; }
		}

		public string HotelName
		{
			get { return _hotelname; }
			set
			{
				if ( value != null && value.Length > 100)
					value = value.Substring(0, 100 );
				_hotelname = value;
			}
		}

		public LogisticalInfo LogisticalInfo
		{
			get { return _logisticalInfo; }
			set { _logisticalInfo = value; }
		}

        public static String SortExpression
        {
            get { return _sortExpression; }
            set { _sortExpression = value; }
        }

        public static SortDirection SortDirection
        {
            get { return _sortDirection; }
            set { _sortDirection = value; }
        }
		#endregion
		
        #region IComparable Methods
        public int CompareTo(object obj)
        {
			if (!(obj is HotelRoomBooking))
				throw new InvalidCastException("This object is not of type HotelRoomBooking");
			
			int relativeValue;
			switch (SortExpression)
			{
				case "Id":
					relativeValue = this.Id.CompareTo(((HotelRoomBooking)obj).Id);
					break;
				case "HotelRoomTypeID":
					relativeValue = this.HotelRoomTypeID.CompareTo(((HotelRoomBooking)obj).HotelRoomTypeID);
					break;
				case "RoomNumber":
					relativeValue = this.RoomNumber.CompareTo(((HotelRoomBooking)obj).RoomNumber);
					break;
				case "HotelID":
					relativeValue = this.HotelID.CompareTo(((HotelRoomBooking)obj).HotelID);
					break;
                default:
                    goto case "Id";
			}
            if (HotelRoomBooking.SortDirection == SortDirection.Ascending)
				relativeValue *= -1;
			return relativeValue;
		}
		#endregion
	}

	#endregion
}
